//
//  MeTabBarViewController.m
//  MeLive
//
//  Created by liulei on 2017/5/2.
//  Copyright © 2017年 liulei. All rights reserved.
//

#import "MeTabBarViewController.h"
#import "MeNavigationViewController.h"
#import "MeHomeViewController.h"
#import "MeMyCenterViewController.h"

@interface MeTabBarViewController ()<UITabBarControllerDelegate>

@end

@implementation MeTabBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.delegate = self;
    
    [self setup];
}

- (void)setup
{
    [self addChildViewController:[[MeHomeViewController alloc] init] imageNamed:@"toolbar_home"];
    UIViewController *showTime = [[UIViewController alloc] init];
    showTime.view.backgroundColor = [UIColor whiteColor];
    [self addChildViewController:showTime imageNamed:@"toolbar_live"];
    [self addChildViewController:[[MeMyCenterViewController alloc] init] imageNamed:@"toolbar_me"];
}

- (void)addChildViewController:(UIViewController *)childController imageNamed:(NSString *)imageName
{
    MeNavigationViewController *nav = [[MeNavigationViewController alloc] initWithRootViewController:childController];
    childController.tabBarItem.image = [UIImage imageNamed:imageName];
    childController.tabBarItem.selectedImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_sel", imageName]];
    // 设置图片居中, 这儿需要注意top和bottom必须绝对值一样大
    childController.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
    // 设置导航栏为透明的
    //    if ([childController isKindOfClass:[ProfileController class]]) {
    //        [nav.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    //        nav.navigationBar.shadowImage = [[UIImage alloc] init];
    //        nav.navigationBar.translucent = YES;
    //    }
    [self addChildViewController:nav];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
